///*
// * Main.java
// *
// * Created on 2007. május 16., 20:28
// *
// * To change this template, choose Tools | Template Manager
// * and open the template in the editor.
// */
//
//package Orkomet;
//import com.hp.hpl.jena.db.DBConnection;
//import com.hp.hpl.jena.db.IDBConnection;
//import com.hp.hpl.jena.ontology.OntModel;
//import com.hp.hpl.jena.ontology.OntModelSpec;
//import com.hp.hpl.jena.ontology.OntResource;
//import com.hp.hpl.jena.query.Query;
//import com.hp.hpl.jena.query.QueryExecution;
//import com.hp.hpl.jena.query.QueryExecutionFactory;
//import com.hp.hpl.jena.query.QueryFactory;
//import com.hp.hpl.jena.query.ResultSet;
//import com.hp.hpl.jena.query.ResultSetFormatter;
//import com.hp.hpl.jena.rdf.model.InfModel;
//import com.hp.hpl.jena.rdf.model.Model;
//import com.hp.hpl.jena.rdf.model.ModelFactory;
//import com.hp.hpl.jena.rdf.model.ModelMaker;
//import com.hp.hpl.jena.reasoner.Reasoner;
//import com.hp.hpl.jena.reasoner.ReasonerRegistry;
//import com.hp.hpl.jena.reasoner.ValidityReport;
//import com.hp.hpl.jena.sparql.util.StringUtils;
//import com.hp.hpl.jena.util.iterator.ExtendedIterator;
//import java.sql.SQLException;
//import java.util.Iterator;
//
///**
// *
// * @author Schimi
// */
//public class Main {
//    
//    /** Creates a new instance of Main */
//    public Main() {
//        String className = "org.apache.derby.jdbc.EmbeddedDriver";
//        try {
//            Class.forName(className);                                   // Load the Driver
//        } catch (ClassNotFoundException ex) {
//            ex.printStackTrace();
//        }                                   // Load the Driver
//// Create database connection
//        IDBConnection conn = new DBConnection( "jdbc:derby://localhost:1527/Orkomet", "ork", "ork", "Derby" );
//        ModelMaker maker = ModelFactory.createModelRDBMaker(conn) ;
//// create or open the default model
//       
//        Model schema=maker.openModel("OrkometSchema");
//        Model data=maker.openModel("OrkometData");
//        
////        schema.read("http://purl.org/dc/elements/1.1/");
////        data.read(new StringReader("<?xml version=\"1.0\"?>" +
////                "<!DOCTYPE rdf:RDF PUBLIC \"-//DUBLIN CORE//DCMES DTD 2002/07/31//EN\" " +
////                "\"http://dublincore.org/documents/2002/07/31/dcmes-xml/dcmes-xml-dtd.dtd\">" +
////                "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">" +
////                "  <rdf:Description rdf:about=\"http://www.ilrt.bristol.ac.uk/people/cmdjb/\">" +
////                "    <dc:anyad>Dave Beckett's Home Page</dc:anyad>" +
////                "    <dc:creator>Dave Beckett</dc:creator>" +
////                "    <dc:publisher>ILRT, University of Bristol</dc:publisher>" +
////                "    <dc:date>2002-07-31</dc:date>" +
////                "  </rdf:Description>" +
////                "</rdf:RDF>"),"" );
//        
//        Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
//        reasoner = reasoner.bindSchema(schema);
//        InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
////        for (StmtIterator it = infmodel.listStatements(); it.hasNext();) {
////            Statement elem = it.nextStatement();
////            //   m.contains(elem.getSubject(),m.getP)
////            System.out.println(elem.asTriple());
////            System.out.println("------------------------------");
////        }
//       
//        OntModel ontmodel=ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,infmodel);
//         for (ExtendedIterator it = ontmodel.listClasses(); it.hasNext();) {
//            OntResource or=(OntResource)it.next();
//            or.getVersionInfo();
//         }
////            Statement elem = it.nextStatement();
////            //   m.contains(elem.getSubject(),m.getP)
////            System.out.println(elem.asTriple());
////            System.out.println("------------------------------");
////        }
//        
//        ValidityReport validity = infmodel.validate();
//        if (validity.isValid()) {
//            System.out.println("OK");
//        } else {
//            System.out.println("Conflicts");
//            for (Iterator i = validity.getReports(); i.hasNext(); ) {
//                ValidityReport.Report report = (ValidityReport.Report)i.next();
//                System.out.println(" - " + report);
//            }
//        }
//        
//        String queryString = StringUtils.join("\n", new String[]{
//            "PREFIX dc: <http://purl.org/dc/elements/1.1/>",
//            "SELECT ?x {" ,
//            "    ?x dc:anyad \"Dave Beckett's Home Page\"",
//            "}"
//        }) ;
//        Query query = QueryFactory.create(queryString) ;
//        QueryExecution qexec = QueryExecutionFactory.create(query, data) ;
//        try {
//            ResultSet results = qexec.execSelect() ;
//            ResultSetFormatter.outputAsXML(System.out,results);
//        } finally { qexec.close() ; }
//        
//        
//        
//        try {
//            
//// Close the database connection
//            conn.close();
//        } catch (SQLException ex) {
//            ex.printStackTrace();
//        }
//    }
//    
//    /**
//     * @param args the command line arguments
//     */
//    public static void main(String[] args) {
//        new Main();
//    }
//    
//}
